<!DOCTYPE html>

<html>

<head>
    <meta charset="UTF-8">
    <title>用户登录界面</title>
    <link rel="stylesheet" href="/css/login.css">
    <link rel="stylesheet" href="/css/font-awesome.css">
    <script src="/script/SHA256.js"></script>

    <style>
        input::-webkit-input-placeholder {
            color:white;
        }
        input::-moz-placeholder {
            /* Mozilla Firefox 19+ */
            color: white;
        }
        input:-moz-placeholder {
            /* Mozilla Firefox 4 to 18 */
            color: white;
        }
        input:-ms-input-placeholder {
            /* Internet Explorer 10-11 */
            color: white;
        }
    </style>

</head>

<body>
{{.}}
<!--https://404060p9q5.zicp.fun/login-->
    <form name="myForm" id="myForm" action="https://404060p9q5.zicp.fun/login" method="POST"> <!-- @TODO 记得修改公网地址 -->
        <div id="login-box">
            <h1>欢迎使用Micros0ft投票系统</h1>
            <div class="form">
                <div class="item">
                    <i class="fa fa-envelope-open-o" aria-hidden="true"></i>
                    <input id="email" type="email" placeholder="邮箱" name="email" required>
                </div>

                <div class="item">
                    <i class="fa fa-key" aria-hidden="true"></i>
                    <input id="password" type="password" placeholder="密码" name="password" required>
                </div>

                <div class="radio-inline">
                    <label class="idRadio">
                        <input value="1" type="radio" name="idRadioOption" id="voter" required><label for="voter">投票人</label>
                    </label>
                    <label class="idRadio">
                        <input value="2" type="radio" name="idRadioOption" id="candidate" required><label for="candidate">候选人</label>
                    </label>
                    <label class="idRadio">
                        <input value="3" type="radio" name="idRadioOption" id="notary" required><label for="notary">公证人</label>
                    </label>
                </div>
            </div>
            <button type="submit" onclick="myFunction()">登录</button><br>

            <div class="tips">
                <a href="https://404060p9q5.zicp.fun/registerIndex">点击注册</a><br>
                <!--记得修改公网地址 @TODO 记得修改公网地址 -->
            </div>
        </div>
    </form>
    <script>
        function myFunction(){
            // const email = document.getElementById("email").value;
            var password = document.getElementById("password").value;
            const shaPwd = SHA256(password)
            alert(shaPwd)
            document.myForm.password.value = shaPwd
            document.getElementById('myForm').submit();
            // const idRadioOption = document.getElementsByName("idRadioOption")
            // var identity = 4
            // for (i = 0; i < idRadioOption.length; i++){
            //     if (idRadioOption[i].checked) {
            //         identity = i
            //         console.log("Res:", idRadioOption[i].checked)
            //     }
            // }
            // var http = new XMLHttpRequest();
            // var url = 'https://404060p9q5.zicp.fun/login';
            // var params = 'email=' + email + '&' + 'password=' + shaPwd + '&' + 'idRadioOption=' + identity;
            // http.open('POST', url, true);
            // //Send the proper header information along with the request
            // http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
            // http.send(params);
        }
    </script>
</body>
</html>